package com.dykj.fireFighting.web.rocketmq.producer;

import com.dykj.fireFighting.web.model.report.DevHisWater;
import com.dykj.fireFighting.web.rocketmq.message.InsertDevHisMessage;
import com.dykj.fireFighting.web.rocketmq.message.InsertDevHisWaterMessage;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zhengbo
 */
@Component
public class InsertDevHisWaterProducer {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    public void asyncSend(DevHisWater devHisWater, SendCallback callback) {
        // 创建 Demo01Message 消息
        InsertDevHisWaterMessage insertDevHisWaterMessage = new InsertDevHisWaterMessage();
        insertDevHisWaterMessage.setDevHisWater(devHisWater);
        // 异步发送消息
        rocketMQTemplate.asyncSend(InsertDevHisWaterMessage.TOPIC, insertDevHisWaterMessage, callback);
    }
}
